//
//  SFPCheckAppointmentCell.swift
//  StriveForPregnancy
//
//  Created by iOS-Czz on 2023/11/9.
//

import UIKit

class SFPCheckAppointmentCell: UITableViewCell {
    @IBOutlet var nameLabel: UILabel!
    @IBOutlet var timeLabel: UILabel!
    @IBOutlet var locationLabel: UILabel!
    @IBOutlet var dateLabel: UILabel!
    @IBOutlet var doctorLabel: UILabel!
    @IBOutlet var resultTV: UITextView!
    var refreshBlock: (() -> Void)?
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    var model: SFPCheckAppointmentModel? {
        didSet {
            self.dateLabel.text = self.model?.date
            self.timeLabel.text = self.model?.time
            self.nameLabel.text = self.model?.name
            self.resultTV.text = "Inspection results:" + self.model!.result
            self.locationLabel.text = "Location: " + self.model!.location
            self.doctorLabel.text = "Appointment: " + self.model!.doctor
        }
    }
    @IBAction func gotoEditAction(_ sender: Any) {
        let editView:SFPCheckAddResultView = Bundle.main.loadNibNamed("SFPCheckAddResultView", owner: self, options: nil)?.first as! SFPCheckAddResultView
        editView.model = self.model
        editView.frame = keyWindow!.frame
        editView.addResultBlock = { [self] in 
            refreshBlock?()
        }
        keyWindow?.addSubview(editView)
    }
}
